package com.outstanding.junit.service.impl;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.outstanding.framework.core.PendingException;
import com.outstanding.junit.bo.gateway.GatewayBo;
import com.outstanding.junit.code.ResCode;
import com.outstanding.junit.dao.GatewayDao;
import com.outstanding.junit.dto.voice.VoiceReqDto;
import com.outstanding.junit.service.VoiceService;
import com.outstanding.junit.utils.SystemUtils;



@Service("voiceService")
public class VoiceServiceImpl implements VoiceService {
	
	@Autowired
	private GatewayDao gatewayDao;

	public GatewayDao getGatewayDao() {
		return gatewayDao;
	}

	public void setGatewayDao(GatewayDao gatewayDao) {
		this.gatewayDao = gatewayDao;
	}

	public boolean sendVoice(VoiceReqDto dto) throws PendingException{
		
		if (dto.getMobile().matches("^[1][3,4,5,7,8][0-9]{9}$")) {
			throw new PendingException(ResCode.paramError);
		}
		
		return true;
	}

	public boolean send(VoiceReqDto dto) throws PendingException {
		
		//参数输出
		SystemUtils.outPrint("请求参数",dto.toString());
		
		if (StringUtils.isEmpty(dto.getMobile())) {
			throw new PendingException(ResCode.paramError);
		}
		
		GatewayBo gate = new GatewayBo();
		gate.setGatewayNo("alidayu");
		GatewayBo gateBo = gatewayDao.getGateway(gate);
		
		gatewayDao.queryGatewayList(new GatewayBo());
		
		if (gateBo==null) {
			return false;
		}
		
		return true;
	}
}
